home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / a_to_d / delftips / ti2856.asc < prev    next >
Encoding:
Text File  |  1996-09-15  |  1.2 KB  |  61 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.   PRODUCT  :  Delphi                                 NUMBER  :  2856
  8.   VERSION  :  All
  9.        OS  :  Windows
  10.      DATE  :  August 22, 1995                          PAGE  :  1/1
  11.  
  12.     TITLE  :  How to terminate all running applications
  13.  
  14.  
  15.  
  16.  
  17. Q:  How do I terminate all running tasks?
  18.  
  19. A:  Below is some code that will help if you want to terminate ALL tasks,
  20.     no questions asked.
  21.  
  22. A word of caution, before you run this for the first time, make sure
  23. that you save it and anything else that may have some pending data.
  24.  
  25.  
  26. procedure TForm1.ButtonKillAllClick(Sender: TObject);
  27. var
  28.   pTask   : PTaskEntry;
  29.   Task    : Bool;
  30.   ThisTask: THANDLE;
  31. begin
  32.   GetMem (pTask, SizeOf (TTaskEntry));
  33.   pTask^.dwSize := SizeOf (TTaskEntry);
  34.  
  35.   Task := TaskFirst (pTask);
  36.   while Task do
  37.   begin
  38.     if pTask^.hInst = hInstance then
  39.       ThisTask := pTask^.hTask
  40.     else
  41.       TerminateApp (pTask^.hTask, NO_UAE_BOX);
  42.     Task := TaskNext (pTask);
  43.   end;
  44.   TerminateApp (ThisTask, NO_UAE_BOX);
  45. end;
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57. DISCLAIMER: You have the right to use this technical information
  58. subject to the terms of the No-Nonsense License Statement that
  59. you received with the Borland product to which this information
  60. pertains.
  61.